package SeleniumTest;

import SeleniumTest.test.BaseTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.Assert;

import java.util.concurrent.TimeUnit;


/**
 * Created with IntelliJ IDEA.
 * User: ae
 * Date: 11.07.13
 * Time: 22:27
 * To change this template use File | Settings | File Templates.
 */
public class BuxferMenu extends BaseTest
{

    @Test
    public void MenuTest() {
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.buxfer.com/");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String homeURL = driver.getCurrentUrl();
        Assert.assertEquals(homeURL,"https://www.buxfer.com/");

        driver.manage().window().maximize();

        driver.findElement(By.linkText("Login")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String loginURL = driver.getCurrentUrl();
        Assert.assertEquals(loginURL,"https://www.buxfer.com/slogin");

        driver.findElement(By.id("login_username")).sendKeys("testuser@gmail.com");
        driver.findElement(By.id("login_password")).sendKeys("Pa$$word");
        driver.findElement(By.linkText("Login")).click();
        driver.findElement(By.id("search")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String summaryURL = driver.getCurrentUrl();
        Assert.assertEquals(summaryURL,"https://www.buxfer.com/home#/home");

        driver.findElement(By.id("tab-add_transaction")).click();
        driver.findElement(By.id("rd-inp-transType-2")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String transactURL = driver.getCurrentUrl();
        Assert.assertEquals(transactURL,"https://www.buxfer.com/home#/transaction/add");

        driver.findElement(By.id("tab-reports")).click();
        driver.findElement(By.id("8a068-2-tab-ic")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String reportsURL = driver.getCurrentUrl();
        Assert.assertEquals(reportsURL,"https://www.buxfer.com/home#/reports");

        driver.findElement(By.id("tab-budgets")).click();
        driver.findElement(By.id("env-list-tab-ic")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String budgetsURL = driver.getCurrentUrl();
        Assert.assertEquals(budgetsURL,"https://www.buxfer.com/home#/budgets");

        driver.findElement(By.id("tab-reminders")).click();
        driver.findElement(By.id("rem-cal-tab-ic")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String remindersURL = driver.getCurrentUrl();
        Assert.assertEquals(remindersURL,"https://www.buxfer.com/home#/reminders");

        driver.findElement(By.id("tab-forecast")).click();
        driver.findElement(By.id("pro-tab-ic")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String forecastURL = driver.getCurrentUrl();
        Assert.assertEquals(forecastURL,"https://www.buxfer.com/home#/forecast");

        driver.findElement(By.id("tab-payments")).click();
        driver.findElement(By.id("payments-input-tab-ic")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        String paymentsURL = driver.getCurrentUrl();
        Assert.assertEquals(paymentsURL,"https://www.buxfer.com/home#/payments");

        driver.findElement(By.id("tab-home")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        Assert.assertEquals(summaryURL,"https://www.buxfer.com/home#/home");
        driver.findElement(By.linkText("Get Started")).click();

        driver.quit();
    }
}
